{include file="public_head" /}
<!-- upload -->
<link href="__STATIC__/css/uploads.css" rel="stylesheet">
<!-- upload_arr -->
<link href="__STATIC__/plupload/plupload.css" rel="stylesheet">
<!-- Select2 -->
<link href="__STATIC__/css/select/select2.min.css" rel="stylesheet">
<!-- sku -->
<link href="__STATIC__/css/sku.css" rel="stylesheet" type="text/css">
<!-- Select2 -->
<link href="__STATIC__/css/select/select2.min.css" rel="stylesheet">

<body class="nav-md">

<div class="container body">

    <div class="main_container">

        {include file="public_sidebar,public_nav" /}
        <!-- page content -->
        <div class="right_col" role="main">
            <div class="">

                <div class="page-title">
                    <div class="title_left">
                        <h3>服务订单管理</h3>
                    </div>
                </div>
                <div class="clearfix"></div>
                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_title">
                                <h2>查看订单
                                    <!--<small>different form elements</small>-->
                                </h2>
                                <ul class="nav navbar-right panel_toolbox">
                                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                    </li>
                                    <li><a class="close-link"><i class="fa fa-close"></i></a>
                                    </li>
                                </ul>
                                <div class="clearfix"></div>
                            </div>
                            <div class="x_content">
                                <br/>
                                <form class="form-horizontal form-label-left" enctype="multipart/form-data" action=""
                                      method="post" id="registerForm">
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">所属分类：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{$item.cat_name}->{$item.one_cat}</div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">订 单 号：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{$item.order_number}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">用户账号：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{$item.username}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">下单/退款 时间：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{$item.create_time}{in name="$item.status" value="10,11,12"} / {$item.refund_create_time}{/in}</div>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">服务门店：</label>
                                        <div class="col-md-2 col-sm-6 col-xs-12">
                                            {if condition="$auding_status eq 2"}
                                            <select name="shop_id" class="form-control" style="width: 300px;float: left;" tabindex="-1" >
                                                <option value="0">请选择门店</option>
                                                {foreach :model('shop')->where('auding_status',2)->order('shop_status','asc')->select() as $key=>$vo }
                                                <option value="{$vo.id}" {eq name='$item.shop_id|default=""' value='$vo.id' }selected{/eq}>{switch name="$vo.shop_status"}
                                                {case 1}空闲{/case}
                                                {case 2}{$vo.wait_time_index}-{$vo.wait_time_h}时{$vo.wait_time_m}分{/case}
                                                {/switch}-{$vo.shop_title}</option>
                                                {/foreach}
                                            </select>
                                            {else/}
                                            {:model('shop')->where('id',$item.shop_id)->value('shop_title')}
                                            {/if}
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">{eq name="$item.single_id" value="11"}寄存金额{else/}服务金额{/eq}：</label>
                                        <div class="col-md-1 col-sm-6 col-xs-12" >
                                            <input type="text" placeholder="请填写订单总额" {neq name="$item.status" value="50"}readonly{/neq}
                                                   class="form-control col-md-7 col-xs-12" name="amount"
                                                   value="{$item.order_price|default=''}" datatype="*" nullmsg="请填写订单总额"
                                            >
                                        </div><span style="position: relative;bottom:-8px;">寄存金额为0 就是免费寄存</span>
                                    </div>
                                    {if condition="$item.single_id eq 11 && $item.status eq 6 && $auding_status eq 1"}
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">轮胎寄存时间：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请选择时间区间"
                                                   class="form-control col-md-7 col-xs-12" name="interval_timer"
                                                   id="interval_timer"
                                                   {notempty name="$item.start_time"}
                                                   value="{$item.start_time} / {$item.end_time}"
                                                   {/notempty}
                                            datatype="*"
                                            nullmsg="请选择时间区间" errormsg="请选择时间区间！"
                                            >
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">轮胎组图【160*120】:</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">

                                            <div class="uploader white">
                                                <input type="button" id="logo_upload_btn" class="button" value="批量上传"/>
                                            </div>

                                            <div id="logo_upload_area" style='width:80%'>
                                                <div id='photos_area' class="photos_area clearfix">

                                                    {if condition="($Request.action eq 'update') && ($item.multi_pic neq 'N;')"}
                                                    {foreach :unserialize($item['multi_pic']) as $picValue}
                                                    <div class="item">
                                                        <input type="hidden" name="picArr[]" value="{$picValue}">
                                                        <img src="__PUBLIC__/{$picValue}" width="100px" height="100px">
                                                        <div class="operate">
                                                            <i class="toleft">左移</i>
                                                            <i class="toright">右移</i>
                                                            <i class="del">删除</i>
                                                        </div>
                                                    </div>
                                                    {/foreach}
                                                    {/if}

                                                </div>
                                                <div class="alert alert-success" role="alert"
                                                     style="margin:10px 0;"><strong><span
                                                        class="glyphicon glyphicon-flag"></span>点击批量上传按钮上传多张图片:</strong>&nbsp;&nbsp;单张图片大小不超过500KB,格式为jpg,png,gif,jpeg
                                                </div>

                                            </div>

                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">轮胎寄存备注：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12">
                                            <textarea type="text" placeholder="请填写备注" style="width: 380px;height: 150px;"
                                                      class="form-control col-md-7 col-xs-12" name="remark"

                                            >{$item.remark|default=''}</textarea>
                                        </div>
                                    </div>
                                    {/if}
                                    {if condition="$item.single_id eq 11"}
                                    {in name="$item.status" value="4,5"}

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">寄存时间：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                           {$item.start_time}-{$item.end_time}
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">轮胎组图：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12 example" style="margin-top: 10px;">
                                            {foreach :unserialize($item['multi_pic']) as $picValue}
                                            <img class="" src="/{$picValue}" width="180" height="110" onerror="this.src='/default_img.png'">

                                            {/foreach}
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">寄存备注：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            {$item.remark|default=''}
                                        </div>
                                    </div>
                                    {/in}
                                    {/if}
                                    {neq name="$item.single_id" value="11"}
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">运费金额：</label>
                                        <div class="col-md-1 col-sm-6 col-xs-12" >
                                            <input type="text" placeholder="填写运费就是上门配送" onchange=""
                                            class="form-control col-md-7 col-xs-12" name="freight" {neq name="$item.status" value="50"}readonly{/neq}
                                            value="{$item.freight|default=''}" datatype="*" nullmsg="请填写运费金额"
                                            >
                                        </div><span style="position: relative;bottom:-8px;">填写大于0的运费金额 就是上门服务</span>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">联系人：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12" >
                                            <input type="text" placeholder="请填写联系人"
                                            class="form-control col-md-7 col-xs-12" name="shipping_name" {neq name="$item.status" value="50"}readonly{/neq}
                                            value="{$item.shipping_name|default=''}"
                                            >
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">联系人手机号：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12" >
                                            <input type="text" placeholder="请填写联系人手机号" {neq name="$item.status" value="50"}readonly{/neq}
                                            class="form-control col-md-7 col-xs-12" name="shipping_phone"
                                            value="{$item.shipping_phone|default=''}"
                                            >
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">配送区域：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12" >
                                            <input type="text" placeholder="请填写配送区域" {neq name="$item.status" value="50"}readonly{/neq}
                                            class="form-control col-md-7 col-xs-12" name="shipping_province"
                                            value="{$item.shipping_province|default=''}"
                                            >
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">配送详细地址：</label>
                                        <div class="col-md-4 col-sm-6 col-xs-12" >
                                            <input type="text" placeholder="请填写配送详细地址" {neq name="$item.status" value="50"}readonly{/neq}
                                            class="form-control col-md-7 col-xs-12" name="shipping_address"
                                            value="{$item.shipping_address|default=''}"
                                            >
                                        </div>
                                    </div>
                                    {/neq}
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">服务方式：</label>
                                        <div class="col-md-1 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            {switch name="item.shipping"}
                                            {case 1}商家配送{/case}
                                            {case 2}到店自取{/case}
                                            {/switch}
                                        </div>
                                    </div>

                                    {in name="$item.status" value="10,11,12"}
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">退款金额：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{$refund.amount}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">退款理由：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{$refund.title}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">退款说明：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{$refund.explain}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                        </div>
                                    </div>
                                    {/in}

                                    {in name="$item.service_type_id" value="1,2"}
                                    {eq name="$item.service_type_id" value="1"}
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">投保险种：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{:implode(' ',$item.service_info.type_id_name)}</div>
                                        </div>
                                    </div>
                                    {/eq}
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">投保人：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{$item.service_info.protecteder}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">手机号码：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <div>{$item.service_info.phone}&nbsp;&nbsp;&nbsp;&nbsp;</div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">实名认证：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12 example" style="margin-top: 10px;">
                                            <img class="" src="/{$item.service_info.protecter_face}" width="180" height="110" onerror="this.src='/default_img.png'"> <img class="smallimg" src="/{$item.service_info.protecter_back}" width="180" height="110" onerror="this.src='/default_img.png'">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">被保车辆：</label>
                                        <div class="example col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <img class="" src="/{$item.service_info.car_face}" width="180" height="110" onerror="this.src='/default_img.png'"> <img class="smallimg" src="/{$item.service_info.car_back}" width="180" height="110" onerror="this.src='/default_img.png'">
                                        </div>
                                    </div>
                                    {/in}

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">订单状态：</label>
                                        <div class="col-md-1 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            {switch name="item.status"}
                                            {case 50}等待沟通{/case}
                                            {case 1}未支付{/case}
                                            {case 6}进行中--{switch name="item.code"}{case 1}等待验证{/case}{case 2} 已验证{/case}{/switch}{/case}
                                            {case 5}已确认{/case}
                                            {case 4}已评价{/case}
                                            {case 10}退款中{/case}
                                            {case 11}退款成功{/case}
                                            {case 12}退款失败{/case}
                                            {case 20}取消订单{/case}
                                            {/switch}
                                            <br/>

                                        </div>

                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">是否开发票：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            {switch name="item.bill"}{case 1}开{/case}{case 2} 否{/case}{default /}{/switch}<br>
                                            {eq name="$item.bill" value="1"}
                                            发票类型：{switch name="item.bill_type"}{case 1}电子{/case}{case 2} 普通{/case}{case 3} 增值税{/case}{default /}{/switch}<br>
                                            发票抬头：{switch name="item.bill_header"}{case 1}个人{/case}{case 2} 单位{/case}{default /}{/switch}<br>
                                            发票内容：{$item.bill_content}<br>
                                            发票电话：{$item.bill_phone}<br>
                                            电子邮箱：{$item.bill_email}<br>
                                            发票编号：{$item.bill_number}<br>
                                            {/eq}
                                        </div>
                                    </div>
                                    {eq name=":session('auding_status')" value="1"}
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">服务人员提成：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <table class="table table-striped table-bordered table-hover">
                                                <thead>
                                                <th>服务人员</th>
                                                <th>提成金额</th>
                                                {in name="$item.status" value="5,4"}
                                                <th>创建时间</th>
                                                {/in}
                                                {if condition="$item.status eq 6 && $item.code eq 2 && $item.shop_id gt 0 && $auding_status eq 1 && strtotime($item.code_time) egt (time()-300)"}
                                                <th>操作</th>
                                                {/if}
                                                </thead>
                                                {if condition="$item.status eq 6 && $item.code eq 2 && $item.shop_id gt 0 && $auding_status eq 1 && strtotime($item.code_time) egt (time()-300)"}
                                                <tbody id="fieldtr">
                                                {volist name="shop_assignor_records" id="list"}
                                                <tr>
                                                    <td>
                                                        <select name="assignor_id[]" class="form-control" tabindex="-1">
                                                            {volist name="$shop_assignor" id="li"}
                                                            <option value="{$li.id}" {eq name="$li.id" value="$list.assignor_id"}selected{/eq}>{$li.name}</option>
                                                            {/volist}
                                                        </select>
                                                    </td>
                                                    <td><input type="text" name="assignor_price[]" style="width:100px;" value="312"/></td>
                                                    <td><a href="javascript:;" onclick="delThis($(this),{$list.id})">删除</a></td>
                                                </tr>
                                                {/volist}
                                                </tbody>
                                                <tbody align="right">
                                                <tr>
                                                    <td colspan="3"><a href="javascript:;" class="addNewTr" title="新增一条">新增一条</a></td>
                                                </tr>
                                                </tbody>
                                                {/if}
                                                {in name="$item.status" value="5,4"}
                                                <tbody id="fieldtr">
                                                {volist name="shop_assignor_records" id="list"}
                                                <tr>
                                                    <td>
                                                        {$list.name}
                                                    </td>
                                                    <td>{$list.assignor_price}</td>
                                                    <td>{$list.create_time}</td>
                                                </tr>
                                                {/volist}
                                                </tbody>

                                                {/in}
                                            </table>
                                        </div>
                                    </div>
                                    {/eq}



                                    {in name="item.status" value="10"}
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">退款状态：</label>
                                        <div class="col-md-1 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                            <select name="status" class="form-control" style="width: 200px;float: left;" tabindex="-1" {in name='item.status' value='11,12'}disabled{/in}>
                                            <option value="11" {eq name='item.status' value='11'}selected{/eq}>申请退款成功</option>
                                            <option value="12" {eq name='item.status' value='12'}selected{/eq}>申请退款失败</option>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">未退款理由：</label>
                                        <div class="col-md-1 col-sm-6 col-xs-12" style="margin-top: 10px;">
                                                <textarea type="text" placeholder="未退款理由,不填写留空" style="width: 500px;height: 100px;"
                                                          class="form-control col-md-7 col-xs-12" name="fail_explain">{$refund_find.message|default=''}</textarea>
                                            <div style="width:500px;clear: both">
                                                <span style="font-size: 16px;color: red">注：只有在退款状态是退款失败的时候填写</span>
                                            </div>
                                        </div>
                                    </div>
                                    {/in}

                                    <div class="ln_solid"></div>
                                    <div class="form-group">
                                        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                                            {neq name="$item.single_id" value="11"}
                                            {php}
                                            if($item['status'] == 50){
                                            echo '<button type="submit" class="btn btn-primary">确认金额及门店</button>';
                                            }
                                            {/php}
                                            {if condition="$item.status eq 6 && $item.code eq 1 && $auding_status eq 2"}
                                            <button type="submit" class="btn btn-primary">指派门店</button>
                                            {/if}
                                            {if condition="$item.status eq 6 && $item.code eq 2 && $item.shop_id gt 0 && $auding_status eq 1 && strtotime($item.code_time) egt (time()-300)"}
                                            <button type="submit" class="btn btn-primary">确认订单</button>
                                            {/if}
                                            {in name="$item.status" value="10"}
                                            <button type="submit" class="btn btn-primary">退款提交</button>
                                            {/in}
                                            {/neq}
                                            {if condition="$item.single_id eq 11 && $item.status eq 50 && $auding_status eq 2"}
                                            <button type="submit" class="btn btn-primary">指派门店(轮胎寄存)</button>
                                            {/if}
                                            {if condition="$item.single_id eq 11 && $item.status eq 6 && $item.code eq 2 && $item.shop_id gt 0 && $auding_status eq 1 "}
                                            <button type="submit" class="btn btn-primary">确定订单(轮胎寄存)</button>
                                            {/if}
                                            {in name="$item.status" value="50,1"}
                                            <a onclick="cancel({$item.member_id},{$item.id})" class="btn btn-primary">取消订单</a>
                                            {/in}
                                            <a type="reset" class="btn btn-success" onclick="history.go(-1)">返回</a>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>


            </div>
            <!-- /page content -->

        </div>

    </div>
</div>


{include file="public_foot" /}


<link rel="stylesheet" href="/zoomify.min.css">

<script src="/zoomify.min.js"></script>
<script type="text/javascript">
    $('.example img').zoomify();
</script>
<!-- validform -->
<script src="__STATIC__/js/Validform_v5.3.2_min.js"></script>
<script src="__STATIC__/js/layer.js"></script>
<!--select-->
<script src="__STATIC__/js/select/select2.full.min.js"></script>
<style>


</style>
<script>

    $('.tt').click(function(){
        //$(this).toggleClass('max');
       // $(this).toggleClass('min');
    });
    function cancel(member_id,order_id){
        $(function(){
//            var member_id = member_id;
            //var order_id = order_id;
            //$('#send').click(function(){

            $.ajax({

                type: "POST",

                url: "{:url('index/order/cancel')}",

                data: {member_id:member_id, order_id:order_id},

                dataType: "json",

                success: function(data){

                    //  $('#resText').empty();   //清空resText里面的所有内容
                    //var obj = JSON.parse(data);
                    if(data.code == 200){
                        layer.msg('订单取消成功');
                        history.go(0);
                        window.location.href = "{:url('index')}"
                    }
                    else{
                        layer.msg('取消失败');
                    }
                    //var html = '';

//                        $.each(data, function(commentIndex, comment){
//
//                            html += '<div class="comment"><h6>' + comment['username']
//
//                                + ':</h6><p class="para"' + comment['content']
//
//                                + '</p></div>';
//
//                        });
//
//                        $('#resText').html(html);

                }

            });

            /// });

        });
    }
</script>
<script>
    $('.zoomify').each(function(){
        var zoomed = $(this).hasClass('zoomed');
        if(zoomed == true){
           // alert(1);
            $(this).css("width","1000px");
        }
    });
    // validform
    $(function () {

        $.Tipmsg.r = null;

        var showmsg = function (msg) {
            //假定你的店铺商品提示方法为showmsg， 在方法里可以接收参数msg，当然也可以接收到o及cssctl;
            alert(msg);
        }

        // select2
        $(".select2_single").select2({
            placeholder: "请选择快递公司",
            allowClear: true
        });

        $(".select2_single2").select2({
            placeholder: "请选择订单状态",
            allowClear: true
        });


        $("#registerForm").Validform({
            tiptype: function (msg) {
                layer.msg(msg);
            },
            tipSweep: true
        });
    })
</script>

<!-- upload_arr -->
<script src="__STATIC__/js/upload.photos.js"></script>
<script type="text/javascript" src="__STATIC__/plupload/plupload.full.min.js"></script>
<!-- Times -->
<script src='__STATIC__/js/datepicker/WdatePicker.js'></script>
<!-- validform -->
<script src="__STATIC__/js/Validform_v5.3.2_min.js"></script>
<script src="__STATIC__/js/layer.js"></script>
<!-- select -->
<script src="__STATIC__/js/select/select2.full.min.js"></script>
<!-- upload -->
<script type="text/javascript" src="__STATIC__/js/uploadPreview.js"></script>

<!-- ueditor -->
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">



</script>
<script>


    // validform
    $(function () {
        $(".select2_multiple").select2({
            maximumSelectionLength: 0,
            placeholder: "请选择关联栏目",
            allowClear: true
        });
        $.Tipmsg.r = null;

        var showmsg = function (msg) {
            //假定你的店铺商品提示方法为showmsg， 在方法里可以接收参数msg，当然也可以接收到o及cssctl;
            alert(msg);
        }
        $("#registerForm").Validform({
            tiptype: function (msg) {
                layer.msg(msg);
            },
            tipSweep: true
        });


        // upload
        new uploadPreview({UpBtn: "up_img", DivShow: "imgdiv", ImgShow: "imgShow"});

        // select2
        $(".select2_single").select2({
            placeholder: "请选择分类",
            allowClear: true
        });

        // 组图排序 删除图片
        $(".toleft").live("click", function () {
            var item = $(this).parent().parent(".item");
            var item_left = item.prev(".item");
            if ($("#photos_area").children(".item").length >= 2) {
                if (item_left.length == 0) {
                    item.insertAfter($("#photos_area").children(".item:last"));
                } else {
                    item.insertBefore(item_left);
                }
            }

        })

        $(".toright").live("click", function () {
            var item = $(this).parent().parent(".item");
            var item_right = item.next(".item");
            if ($("#photos_area").children(".item").length >= 2) {
                if (item_right.length == 0) {
                    item.insertBefore($("#photos_area").children(".item:first"));
                } else {
                    item.insertAfter(item_right);
                }
            }
        })

        $(".del").live("click", function () {
            $(this).parent().parent(".item").remove();
        })

        $(":radio").click(function () {

            if (this.checked) {
                if ($(this).attr("id") == "freight_type_1") {
                    $("#immobilization").show();
                    $("#template").hide();
                }else{
                    $("#immobilization").hide();
                    $("#template").hide();
                }
            }
        });
    });

    // 组图上传
    var uploader = new plupload.Uploader({
        runtimes: 'html5,flash,silverlight,html4',
        browse_button: 'logo_upload_btn',
        url: "/index.php/client/shop_goods/uploadarr.html",
        flash_swf_url: '__STATIC__/plupload/Moxie.swf',
        silverlight_xap_url: '__STATIC__/plupload/Moxie.xap',
        filters: {
            max_file_size: '5000kb',
            mime_types: [
                {title: "files", extensions: "jpg,png,gif,jpeg"}
            ]
        },
        multi_selection: true,
        init: {
            FilesAdded: function (up, files) {
                $("#btn_submit").attr("disabled", "disabled").addClass("disabled").val("正在上传...");
                var item = '';
                plupload.each(files, function (file) { //遍历文件
                    item += "<div class='item' id='" + file['id'] + "'><div class='progress'><span class='bar'></span><span class='percent'>0%</span></div></div>";
                });
                $("#photos_area").append(item);
                uploader.start();
            },
            UploadProgress: function (up, file) { //上传中，显示进度条
                var percent = file.percent;
                $("#" + file.id).find('.bar').css({"width": percent + "%"});
                $("#" + file.id).find(".percent").text(percent + "%");
            },
            FileUploaded: function (up, file, info) {

                var data = eval("(" + info.response + ")");

                $("#" + file.id).html("<input type='hidden' name='picArr[]' value='" + data.src + "'><img src='__PUBLIC__/" + data.src + "' alt='" + data.name + "' width='100px' height='100px'><div class='operate'><i class='toleft'>左移</i><i class='toright'>右移</i><i class='del'>删除</i></div>")
                $("#btn_submit").removeAttr("disabled").removeClass("disabled").val("提 交");
                if (data.error != 0) {
                    layer.msg(data.error);
                }
            },
            Error: function (up, err) {
                layer.msg(err.message);
                $("#btn_submit").removeAttr("disabled").removeClass("disabled").val("提 交");
            }
        }
    });
    uploader.init();


    function delThisTr(trobj)
    {
        trobj.parent().parent().remove();
    }

    function delThis(trobj,id)
    {
        if(confirm('确认删除？')){
            $.ajax({
                url : '{:url("shop_assignor_records")}',
                data:{'id':id},
                dataType:'html',
                success:function(data){
                    data = JSON.parse(data);
                    console.log(data)
                    if(data.code == 200){
                        layer.msg('删除成功');
                        trobj.parent().parent().remove();
                    }else{
                        layer.msg(data.message);
                    }
                }
            });
        }
    }
    var assgioner = {$shop_assignor};
    console.log(assgioner);
    var s = [];
    var ss = [];
    $.each(assgioner, function(k,v){
        ss += '<option value="'+v.id+'">'+v.name+'</option>';
    });

    s = '<tr><td><select name="status" class="form-control" tabindex="-1">' + ss
    s += '</select></td>';
    console.log(s);
    $(".addNewTr").click(function(){
      str = '<tr><td><select name="assignor_id[]" class="form-control" tabindex="-1">' + ss +
            '</select></td>' +
            '<td><input type="text" name="assignor_price[]" style="width:100px;" /></td>' +
            '<td><a href="javascript:;" onclick="delThisTr($(this))">删除</a></td></tr>';
        $("#fieldtr").append(str);
    });






</script>
<!-- daterangepicker -->
<script src="__STATIC__/js/datepicker/daterangepicker.js"></script>
<script type="text/javascript">
    $('#interval_timer').daterangepicker(null,
        function(start, end, label) {
            console.log(start.toISOString(), end.toISOString(), label);
        });
    var str = '<a href="http://www.baidu.com">链接111111111</a> ';
    var reg1 = /href=\"(.+)\"/g;
    var reg2 = /\">(.+)<\/a>/g;
    var retVal1 = reg1.exec(str);
    var retVal2 = reg2.exec(str);
    //alert(retVal1[1]);
    //alert(retVal2[1]);
</script>
<script src="__STATIC__/js/sku.js"></script>
</body>

</html>
